package com.itheima.aop;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author itheima
 * @TODO 3、切面类：需要放入到spring容器中
 */
@Component
@Aspect
public class TransactionAspect {

    /**
     * 切入点
     */
    @Pointcut("execution(* com.itheima.service.impl.UserServiceImpl.save())")
    public void myPoint() {

    }

    /**
     * 前置通知
     */
    @Before("myPoint()")
    public void before() {
        System.out.println("开启事务");
    }

    /**
     * 最终通知
     */
    @After("myPoint()")
    public void after() {
        System.out.println("提交事务");
    }
}
